package com.yugao.fintech.antelope.infra.weixin.mp.listener;

import com.yugao.fintech.antelope.dynamic.config.core.event.ConfigDeleteEvent;
import com.yugao.fintech.antelope.infra.weixin.mp.handler.WxMpHandler;
import com.yugao.fintech.antelope.base.model.enums.ConfigKeyEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;


@Slf4j
@Component
public class WxMpConfigDeleteListener {
    @Autowired
    private WxMpHandler mpProcess;

    @EventListener(ConfigDeleteEvent.class)
    public void delete(ConfigDeleteEvent event) {
        Object configKey = event.getSource();
        if (ConfigKeyEnum.WX_MP.getKey().equals(configKey)) {
            mpProcess.deleteCache();
            log.info("delete weixin mp client: {}", configKey);
        }
    }
}
